#include "level.h"

Level::Level(qint32 id, const QString &name) :
    id(id), name(name), locked(false)
{
//    linesList = new QLinkedList<Line*>();
//    pointsList = new QLinkedList<Point*>();
}

void Level::addLine(Line *line)
{
    linesList.push_back(line);
}

void Level::addPoint(Point *point)
{
    pointsList.push_back(point);
}

const QLinkedList<Line*>& Level::getLinesList()
{
    return linesList;
}

const QLinkedList<Point*>& Level::getPointsList()
{
    return pointsList;
}

void Level::clear()
{
    while (!pointsList.isEmpty()) {
        Point* p = pointsList.first();
        pointsList.removeFirst();
        delete p;
    }
    while (!linesList.isEmpty()) {
        Line* l = linesList.first();
        linesList.removeFirst();
        delete l;
    }
//    QLinkedList<Point *>::const_iterator pit;
//    for (pit=pointsList.begin(); pit!=pointsList.end(); pit++) {
//        delete (*pit);
//    }
//    while ()

//    QLinkedList<Line *>::const_iterator lit;
//    for (lit=linesList.begin(); lit!=linesList.end(); lit++) {
//        qDebug() << *lit;
//        delete (*lit);
//    }

//    pointsList.clear();
//    linesList.clear();
}

int Level::getId()
{
    return id;
}

const QString& Level::getName()
{
    return name;
}

Level::~Level()
{
    clear();
//    delete linesList;
//    delete pointsList;
}
